<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"
    import="reports.Report, java.util.*;"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sales Report</title>
</head>
<body>

<%

//load cookies
	Cookie[] cookies = request.getCookies();
	Cookie c = null; 
	HashMap<String, String> reportParam = new HashMap<String, String>(); 

	for (int i = 0; i < cookies.length; i++) {
		c = cookies[i]; 
		if (reportParam.containsKey(c.getName()) == false) 
			reportParam.put(c.getName(), c.getValue()); 
	}

	String report = reportParam.get("report"); 
	String period = reportParam.get("period"); 
	String startDate = reportParam.get("startDate"); 
	String startMonth = reportParam.get("startMonth");  
	String startYear = reportParam.get("startYear"); 
	String endDate = reportParam.get("endDate"); 
	String endMonth = reportParam.get("endMonth");  
	String endYear = reportParam.get("endYear");  
	
 
	Report r = new Report();
	
	//Purchase, Return Exchange
	
	//get sales data
	HashMap<String, ArrayList<Double>> salesData = r.getData(startDate, startMonth, startYear, endDate, endMonth, endYear, "Purchase"); 
	
	TreeSet<String> sdKeys = (TreeSet<String>) salesData.keySet(); 
	Iterator itr = sdKeys.iterator(); 
	while (itr.hasNext()) {
		String key = (String) itr.next(); 
		double quantity = salesData.get(key).get(0); 
		double price = salesData.get(key).get(1); 
		out.println(key + "  " + quantity + "   " + price); 
	}
	
	//get exchange data
	
	
	//get return data
	

//total sales for search 
	//out.println(r.getTotalSales(startDate, startMonth, startYear, endDate, endMonth, endYear)); 
//total sales by item for search
//total sales for search by period
//total salse by item for search by period. 

%>



<p>Sales</p>
</body>
</html>